<nz-modal [(nzVisible)]="isVisible" [nzMaskClosable]="false" [nzTitle]="teacher.id ? '教师信息详情' : '新增教师信息'"
  (nzOnCancel)="handleCancel()" [nzFooter]="detailFooter" nzWidth="1200">

  <form nz-form [formGroup]="validateForm" #myForm="ngForm">
    <div nz-row [nzGutter]="16">
      <b style="color: red;">基本信息</b>
      <nz-divider nzType="horizontal"></nz-divider>
      <div nz-col [nzSpan]="7">
        <nz-form-item nzFlex nz-row>
          <nz-form-label [nzSpan]="10" nzRequired>所属学院</nz-form-label>
          <nz-form-control [nzSpan]="14">
            <app-academy-select [(academyId)]="teacher.academyId" [academyName]="teacher.academyName"
              [isPreView]="isPreView" *ngIf="!isPreView; else academyTemp">
            </app-academy-select>
            <ng-template #academyTemp>
              <div class="editable-cell">
                <div class="editable-cell-value-wrap text-truncate">
                  {{ teacher?.academyName }}
                </div>
              </div>
            </ng-template>
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="8">
        <nz-form-item nzFlex nz-row>
          <nz-form-label [nzSpan]="10" nzFor="code" nzRequired><span>
              教师编号
              <i nz-icon nz-tooltip [nzTitle]="'用于注册登录账号，密码默认为' + defualtPW" style="color: red;"
                nzType="question-circle" nzTheme="outline"></i> </span></nz-form-label>
          <nz-form-control [nzSpan]="14" nzHasFeedback nzValidatingTip="验证中..." [nzErrorTip]="codeErrorTpl">
            <input nz-input formControlName="code" [(ngModel)]="teacher.code" [placeholder]="'教师编号必填'"
              *ngIf="!isPreView; else codeTemp">
            <ng-template #codeErrorTpl let-control>
              <ng-container *ngIf="control.hasError('required')">
                请输入教师编号!
              </ng-container>
              <ng-container *ngIf="control.hasError('duplicated')">
                该教师编号已存在!
              </ng-container>
              <ng-container *ngIf="control.hasError('blank')">
                不可输入空格!
              </ng-container>
            </ng-template>
            <ng-template #codeTemp>
              <div class="editable-cell">
                <div class="editable-cell-value-wrap text-truncate">
                  {{ teacher?.code }}
                </div>
              </div>
            </ng-template>
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="8">
        <nz-form-item nzFlex nz-row>
          <nz-form-label [nzSpan]="10" nzFor="teacherBaseType" nzRequired>教师名称</nz-form-label>
          <nz-form-control [nzSpan]="14" nzHasFeedback [nzErrorTip]="nameErrorTpl">
            <input nz-input formControlName="name" [(ngModel)]="teacher.name" placeholder="教师名称必填"
              *ngIf="!isPreView; else nameTemp">
            <ng-template #nameErrorTpl let-control>
              <ng-container *ngIf="control.hasError('required')">
                请输入教师名称!
              </ng-container>
              <ng-container *ngIf="control.hasError('blank')">
                不可输入空格!
              </ng-container>
            </ng-template>
            <ng-template #nameTemp>
              <div class="editable-cell">
                <div class="editable-cell-value-wrap text-truncate">
                  {{ teacher?.name }}
                </div>
              </div>
            </ng-template>
          </nz-form-control>
        </nz-form-item>
      </div>
    </div>

    <div nz-row [nzGutter]="24">
      <div nz-col [nzSpan]="7">
        <nz-form-item nzFlex nz-row>
          <nz-form-label nzFor="gender" nzRequired [nzSpan]="10">性别</nz-form-label>
          <nz-form-control nz-col [nzSpan]="14" nzHasFeedback [nzErrorTip]="genderErrorTpl">
            <nz-select [(ngModel)]="teacher.gender" formControlName="gender" nzAllowClear nzPlaceHolder="请选择性别"
              *ngIf="!isPreView; else genderTemp">
              <nz-option nzValue="MALE" nzLabel="男"></nz-option>
              <nz-option nzValue="FEMALE" nzLabel="女"></nz-option>
            </nz-select>
            <ng-template #genderErrorTpl let-control>
              <ng-container *ngIf="control.hasError('required')">
                请选择性别!
              </ng-container>
            </ng-template>
            <ng-template #genderTemp>
              <div class="editable-cell">
                <div class="editable-cell-value-wrap text-truncate">
                  {{ teacher?.gender === 'MALE' ? '男' : '女' }}
                </div>
              </div>
            </ng-template>
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="8">
        <nz-form-item nzFlex nz-row>
          <nz-form-label nzFor="degreeType" nzRequired [nzSpan]="10">学历</nz-form-label>
          <nz-form-control nz-col [nzSpan]="14" nzHasFeedback [nzErrorTip]="degreeTypeErrorTpl">
            <nz-select [(ngModel)]="teacher.degreeType" formControlName="degreeType" nzAllowClear nzPlaceHolder="请选择学历"
              *ngIf="!isPreView; else degreeTypeTemp">
              <nz-option nzValue="MIDDLE_SCHOOL" nzLabel="初中"></nz-option>
              <nz-option nzValue="SECONDARY" nzLabel="中专"></nz-option>
              <nz-option nzValue="HIGH_SCHOOL" nzLabel="高中"></nz-option>
              <nz-option nzValue="ASSOCIATE" nzLabel="大专"></nz-option>
              <nz-option nzValue="BACHELOR" nzLabel="本科"></nz-option>
              <nz-option nzValue="GRADUATE" nzLabel="研究生"></nz-option>
              <nz-option nzValue="DOCTORAL" nzLabel="博士"></nz-option>
              <nz-option nzValue="POST_DOCTORAL" nzLabel="博士后"></nz-option>
            </nz-select>
            <ng-template #degreeTypeErrorTpl let-control>
              <ng-container *ngIf="control.hasError('required')">
                请选择学历!
              </ng-container>
            </ng-template>
            <ng-template #degreeTypeTemp>
              <div class="editable-cell">
                <div class="editable-cell-value-wrap text-truncate">
                  {{ 
                  teacher?.degreeType === 'MIDDLE_SCHOOL'
          ? '初中'
          : teacher?.degreeType === 'SECONDARY'
          ? '中专'
          : teacher?.degreeType === 'HIGH_SCHOOL'
          ? '高中'
          : teacher?.degreeType === 'ASSOCIATE'
          ? '大专'
          : teacher?.degreeType === 'BACHELOR'
          ? '本科'
          : teacher?.degreeType === 'GRADUATE'
          ? '研究生'
          : teacher?.degreeType === 'DOCTORAL'
          ? '博士'
          : teacher?.degreeType === 'POST_DOCTORAL'
          ? '博士后'
          : '无' }}
                </div>
              </div>
            </ng-template>
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="8">
        <nz-form-item nzFlex nz-row>
          <nz-form-label nzFor="joinTime" nzRequired [nzSpan]="10">入职时间</nz-form-label>
          <nz-form-control nz-col [nzSpan]="14" nzHasFeedback [nzErrorTip]="joinTimeErrorTpl">
            <nz-date-picker [(ngModel)]="teacher.joinTime" formControlName="joinTime" nzAllowClear
              nzPlaceHolder="请选择入职时间" *ngIf="!isPreView; else joinTimeTemp"></nz-date-picker>
            <ng-template #joinTimeErrorTpl let-control>
              <ng-container *ngIf="control.hasError('required')">
                请选择入职时间!
              </ng-container>
            </ng-template>
            <ng-template #joinTimeTemp>
              <div class="editable-cell">
                <div class="editable-cell-value-wrap text-truncate">
                  {{ teacher?.joinTime | date: 'yyy-MM-dd' }}
                </div>
              </div>
            </ng-template>
          </nz-form-control>
        </nz-form-item>
      </div>
    </div>
    <div nz-row [nzGutter]="24">
      <div nz-col [nzSpan]="7">
        <nz-form-item nzFlex nz-row>
          <nz-form-label nzFor="birthDate" [nzSpan]="10">出生日期</nz-form-label>
          <nz-form-control nz-col [nzSpan]="14" nzHasFeedback>
            <nz-date-picker [(ngModel)]="teacher.birthDate" formControlName="birthDate" nzAllowClear
              nzPlaceHolder="请选择出生日期" *ngIf="!isPreView; else birthDateTemp"></nz-date-picker>
            <ng-template #birthDateTemp>
              <div class="editable-cell">
                <div class="editable-cell-value-wrap text-truncate">
                  {{ teacher?.birthDate | date: 'yyyy-MM-dd' }}
                </div>
              </div>
            </ng-template>
          </nz-form-control>
        </nz-form-item>
      </div>
      <div nz-col [nzSpan]="12">
        <nz-form-item nzFlex nz-row>
          <nz-form-label nzFor="degreeType" nzRequired [nzSpan]="7">教师身份</nz-form-label>
          <nz-form-control nz-col [nzSpan]="15" nzHasFeedback [nzErrorTip]="degreeTypeErrorTpl">
            <nz-radio-group [(ngModel)]="identity" formControlName="identity" nzPlaceHolder="请选择教师身份"
              *ngIf="!isPreView && !isCreateSenator; else identityTemp">
              <label nz-radio nzValue="isSenator">教务员</label>
              <label nz-radio nzValue="isInstructor">辅导员</label>
              <label nz-radio nzValue="isTeacher">科任教师</label>
            </nz-radio-group>
            <ng-template #identityErrorTpl let-control>
              <ng-container *ngIf="control.hasError('required')">
                请选择教师身份!
              </ng-container>
            </ng-template>
            <ng-template #identityTemp>
              <div class="editable-cell">
                <div class="editable-cell-value-wrap text-truncate">
                  {{ identity === 'isSenator' ? '教务员' : identity === 'isInstructor' ? '辅导员' : identity === 'isTeacher' ? '科任教师' : '' }}
                </div>
              </div>
            </ng-template>
          </nz-form-control>
        </nz-form-item>
      </div>
    </div>
  </form>

  <ng-template #detailFooter>
    <button nz-button nzType="primary" (click)="save()" *ngIf="!isPreView" [nzLoading]="loading">
      <span>保存</span>
    </button>
    <button nz-button nzType="default" (click)="handleCancel()">关闭</button>
  </ng-template>
</nz-modal>
